<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Element对象</title>
</head>
<body>
<a id="link">点我试一试</a><br>
<input type="button" value="添加属性" id="add_attr_btn"><br>
<input type="button" value="移除属性" id="remove_attr_btn"><br>
</body>

<script>

    document.getElementById("add_attr_btn").onclick = addAtrr;
    document.getElementById("remove_attr_btn").onclick = removeAtrr;
    let link = document.getElementById("link");

    function addAtrr() {
        link.setAttribute("href", "https:www.baidu.com");
    }

    function removeAtrr() {
        link.removeAttribute("href")
    }
</script>
</html>